package com.dji.compose_learning.ui.view

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

/**
 * 这个布局报错！
 */
@Composable
fun NestScrollPage() {
    Surface(modifier = Modifier.fillMaxSize()) {
        Box(contentAlignment = Alignment.Center) {
            Column(modifier = Modifier
                .size(400.dp, 800.dp)
                .verticalScroll(rememberScrollState())
                .background(Color.Gray)) {
//                LazyColumn(state = rememberLazyListState()) {
//                    items(80) {
//                        Text(text = "item$it",
//                            modifier = Modifier.background(MaterialTheme.colorScheme.primary),
//                            color = MaterialTheme.colorScheme.onPrimary)
//                    }
//                }
                Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
                    repeat(100) {
                        Text(text = "item$it",
                            modifier = Modifier.background(MaterialTheme.colorScheme.primary),
                            color = MaterialTheme.colorScheme.onPrimary)
                    }
                }
                Row {
                    Text(text = "text1")
                    Text(text = "text2")
                    Text(text = "text3")
                }
                Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
                    repeat(100) {
                        Text(text = "item$it",
                            color = MaterialTheme.colorScheme.onSurface,
                            modifier = Modifier.background(MaterialTheme.colorScheme.surface))
                    }
                }
            }
        }
    }
}

@Composable
fun NestScrollPage1() {
    val gradient = Brush.verticalGradient(0f to Color.Gray, 1000f to Color.White)
    Surface(modifier = Modifier.fillMaxSize()) {
        Box(modifier = Modifier
            .background(Color.LightGray)
            .verticalScroll(rememberScrollState())
            .padding(32.dp)) {
            Column {
                repeat(6) {
                    Box(modifier = Modifier
                        .height(128.dp)
                        .verticalScroll(rememberScrollState())) {
                        Text(text = "Scroll here",
                            modifier = Modifier
                                .border(12.dp, Color.DarkGray)
                                .background(brush = gradient)
                                .padding(24.dp)
                                .height(150.dp))
                    }
                }
            }
        }
    }
}



















